<?php

namespace App\Http\Requests\Wechat\User;


use App\Http\Requests\ApiRequest;
use App\Services\Locale\Language;
use Illuminate\Support\Str;

/**
 * @property int scan_event_id
 * @property string phone
 * @property int customer_id
 * @property string language
 */
class PatchPhoneRequest extends ApiRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $data = [
            'scan_event_id' => 'nullable|int|min:1',
            'language'      => 'nullable|string',
            'customer_id'   => 'required|int|min:1',
            'phone'         => ['required', 'string', 'max:'.self::MAX_STRING],
        ];

//        if (Str::contains($this->language, Language::EN)) {
//            $data['phone'] = ['required', 'string'];
//        } else {
//            $data['phone'] = ['required', 'regex:/^1[34578][0-9]{9}$|^((0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/'];
//        }

        return $data;
    }
}
